home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
The World of Computer Software.iso
/
vsc92nov.zip
/
Cont.h
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-02
|
3KB
|
88 lines
/*
* Cont.h -- Declarations for Scheme Continuations
*
* (C) m.b (Matthias Blume), Apr 1992, HUB/Ger
*
* ident "@(#) Cont.h (C) M.Blume, Humboldt-Uni Berlin, 1.3"
*/
# ifndef CONT_H_
# define CONT_H_
# include "storage.h"
# include "Vector.h"
# include "Code.h"
/*
* A Continuation (activation record) will be established during a ``call''.
* After return of the call there may be the result on the stack or
* another ``call'' has to be carried out.
* The latter case is signalled by setting call_again to the count
* of items on the stack, i.e. the number of arguments + one (the function
* to call). If the plain result is available then call_again == 0.
*/
typedef
struct ScmContinuation {
object_head _;
struct ScmContinuation *father;
ScmCode *code; /* This is NULL for C-Continuations */
unsigned long nxt_stat; /* This is either the pc of a byte-cont.
or the argument for GetScmPrimitive */
void *environ; /* either a vector (Byte) or anything (C) */
ScmVector *constants; /* a copy of code's constants or NULL */
ScmVector *stack; /* this is the stack */
unsigned short stack_top; /* stack_length is part of stack (vector) */
short int shared; /* this record is shared (call/cc) */
unsigned short call_again;
} ScmContinuation;
extern od_vector ScmContinuation_od_vector;
# define ScmContinuation_description (ScmContinuation_od_vector[0])
# ifdef CONT_STACK_FUNCTIONS
extern void ScmCPush (ScmContinuation *cont, void *item);
extern void *ScmCPop (ScmContinuation *cont);
extern void ScmCSetTop (ScmContinuation *cont, void *item);
extern void *ScmCPeek (ScmContinuation *cont);
extern void ScmPush (void *item);
extern void *ScmPop (void);
extern void ScmSetTop (void *item);
extern void *ScmPeek (void);
# else
extern void intern_ScmCPush (ScmContinuation *cont, void *item);
# define ScmCPush(c,x) \
((c)->stack_top>=(c)->stack->length \
?(void)intern_ScmCPush((c),(x)) \
:(void)((c)->stack->array[(c)->stack_top++]=(x)))
# define ScmCPop(c) ((c)->stack->array[--(c)->stack_top])
# define ScmCSetTop(c,x) ((void)((c)->stack->array[(c)->stack_top-1]=(x)))
# define ScmCPeek(c) ((c)->stack->array[(c)->stack_top-1])
extern void intern_ScmPush (void *item);
# define ScmPush(x) \
(ScmCC.stack_top>=ScmCC.stack->length \
?(void)intern_ScmPush(x) \
:(void)(ScmCC.stack->array[ScmCC.stack_top++]=(x)))
# define ScmPop() (ScmCC.stack->array[--ScmCC.stack_top])
# define ScmSetTop(x) ((void)(ScmCC.stack->array[ScmCC.stack_top-1]=(x)))
# define ScmPeek() (ScmCC.stack->array[ScmCC.stack_top-1])
# endif
extern void ScmPushContinuation (unsigned short stackreq);
extern void ScmSetContinuation (ScmContinuation *);
extern ScmContinuation *ScmGetContinuation (void);
extern void ScmRevertToFatherContinuation (unsigned short stackcnt);
extern void *ScmMode (int mode);
extern void ScmSetMode (int mode, void *item);
extern ScmContinuation ScmCC; /* the CURRENT CONTINUATION */
# endif